/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.pe.siass.bussines;

import com.pe.siass.beans.ActorBean;
import com.pe.siass.beans.CasosBean;
import com.pe.siass.beans.ParametrosBean;
import com.pe.siass.dao.ActorDao;
import com.pe.siass.dao.CasosDao;
import com.pe.siass.dao.ParametroDao;
import com.pe.siass.utils.USqlMapLoader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

/**
 *
 * @author Hrengifo
 */
public class ConsultarDaoImpl {

    private SqlSessionFactory sqlSessionFactory = null;
    ActorDao actorDao = new ActorDao();
    CasosDao casosDao = new CasosDao();
    ParametroDao parametroDao = new ParametroDao();

    public ConsultarDaoImpl() throws IOException {
        sqlSessionFactory =  USqlMapLoader.getInstance().getSession();
    }

    public List<ActorBean> selectActor(ActorBean actorBean){
       SqlSession sqlSession = sqlSessionFactory.openSession();
       List<ActorBean> lstParametrosBean = new ArrayList<ActorBean>();
       try{
           lstParametrosBean = actorDao.selectActor(actorBean, sqlSession);
        }catch(Exception e){
           e.printStackTrace();
        }
        finally{
            sqlSession.close();
        }
        return lstParametrosBean;
    }


    public List<CasosBean> selectCasos(CasosBean casosBean){
       SqlSession sqlSession = sqlSessionFactory.openSession();
       List<CasosBean> lstParametrosBean = new ArrayList<CasosBean>();
       try{
           lstParametrosBean = casosDao.selectCasos(casosBean, sqlSession);
        }catch(Exception e){
           e.printStackTrace();
        }
        finally{
            sqlSession.close();
        }
        return lstParametrosBean;
    }

    public List<ParametrosBean> selectParametros(ParametrosBean parametrosBean){
       SqlSession sqlSession = sqlSessionFactory.openSession();
       List<ParametrosBean> lstParametrosBean = new ArrayList<ParametrosBean>();
       try{
           lstParametrosBean = parametroDao.selectParametros(parametrosBean, sqlSession);
        }catch(Exception e){
           e.printStackTrace();
        }
        finally{
            sqlSession.close();
        }
        return lstParametrosBean;
    }
    
}
